<template>
	<view class="container">
		<uni-grid class="TopGrid" :showBorder="false" :square="false">
			<button class="Topbutton">{{btnselect0}}</button>
			<button class="Topbutton">{{btnselect1}}</button>
			<button class="Topbutton">{{btnselect2}}</button>
			<button class="Topbutton">{{btnselect3}}</button>
			<button class="Topbutton">{{btnselect4}}</button>
			<button class="Topbutton">{{btnselect5}}</button>
			<button class="Topbutton">{{btnselect6}}</button>
			<button class="Topbutton">{{btnselect7}}</button>
			<button class="Topbutton">{{btnselect8}}</button>
			<button class="Topbutton">{{btnselect9}}</button>
		</uni-grid>

		<uni-grid class="CentGrid" :showBorder="false" :square="false">
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#FF0000 ;borderColor:#FF0000"
				@tap="btn_SelectA">A</button>
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#000000  ;borderColor:#000000"
				@tap="btn_SelectB">B</button>
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#cd6600;borderColor:#cd6600"
				@tap="btn_Clear">清空</button>
		</uni-grid>
		<uni-grid class="CentGrid" :showBorder="false" :square="false">
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#0000FF  ;borderColor:#0000FF"
				@tap="btn_SelectC">C</button>
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#006650 ;borderColor:#006650"
				@tap="btn_SelectD">D</button>
			<button class="buttonIsEnable" style="color:#ffffff;backgroundColor:#cd6600;borderColor:#cd6600"
				@tap="btn_backspace">退格</button>
		</uni-grid>
		<label class="LabelContent"> 结果:</label>

		<uni-grid class="resultGrid" :showBorder="false" :square="false">
			<button class="Topbutton">{{Results1}}</button>
			<button class="Topbutton">{{Results2}}</button>
			<button class="Topbutton">{{Results3}}</button>
			<button class="Topbutton">{{Results4}}</button>
			<button class="Topbutton">{{Results5}}</button>
			<button class="Topbutton">{{Results6}}</button>
			<button class="Topbutton">{{Results7}}</button>
		</uni-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				btnselect0: '',
				btnselect1: '',
				btnselect2: '',
				btnselect3: '',
				btnselect4: '',
				btnselect5: '',
				btnselect6: '',
				btnselect7: '',
				btnselect8: '',
				btnselect9: '',
				Results1: '',
				Results2: '',
				Results3: '',
				Results4: '',
				Results5: '',
				Results6: '',
				Results7: '',
				List: [],
				Sum: 0,
			}
		},
		onLoad() {
			setTimeout(() => {
				this.getvip()
			}, 2000);
		},
		onUnload() {
			// 页面卸载时清除定时器
			clearTimeout();
		},
		methods: {
			getvip() {
				this.$http('common.getvip').then(res => {
					console.log(res)
					if (res.code === 1) {
						console.log(res.data)

						if (res.data.trailstatus == 1 && res.data.endstatus == 1) {


							uni.showModal({
								title: '温馨提示',
								content: '已到期',
								success: function(res) {
									if (res.confirm) {
										console.log('用户点击确定');
										uni.switchTab({
											url: '/pages/index/index'
										})
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});


							return
						}

					}
				});
			},
			btn_SelectA() {
				if (this.btnselect0 == "") {
					this.btnselect0 = "a"
				} else if (this.btnselect1 == "") {
					this.btnselect1 = "a"
				} else if (this.btnselect2 == "") {
					this.btnselect2 = "a"
				} else if (this.btnselect3 == "") {
					this.btnselect3 = "a"
				} else if (this.btnselect4 == "") {
					this.btnselect4 = "a"
				} else if (this.btnselect5 == "") {
					this.btnselect5 = "a"
				} else if (this.btnselect6 == "") {
					this.btnselect6 = "a"
				} else if (this.btnselect7 == "") {
					this.btnselect7 = "a"
				} else if (this.btnselect8 == "") {
					this.btnselect8 = "a"
				} else if (this.btnselect9 == "") {
					this.btnselect9 = "a"
					this.GetRUsult();
				}
			},
			btn_SelectB() {
				if (this.btnselect0 == "") {
					this.btnselect0 = "b"
				} else if (this.btnselect1 == "") {
					this.btnselect1 = "b"
				} else if (this.btnselect2 == "") {
					this.btnselect2 = "b"
				} else if (this.btnselect3 == "") {
					this.btnselect3 = "b"
				} else if (this.btnselect4 == "") {
					this.btnselect4 = "b"
				} else if (this.btnselect5 == "") {
					this.btnselect5 = "b"
				} else if (this.btnselect6 == "") {
					this.btnselect6 = "b"
				} else if (this.btnselect7 == "") {
					this.btnselect7 = "b"
				} else if (this.btnselect8 == "") {
					this.btnselect8 = "b"
				} else if (this.btnselect9 == "") {
					this.btnselect9 = "b"
					this.GetRUsult();
				}
			},
			btn_SelectC() {
				if (this.btnselect0 == "") {
					this.btnselect0 = "c"
				} else if (this.btnselect1 == "") {
					this.btnselect1 = "c"
				} else if (this.btnselect2 == "") {
					this.btnselect2 = "c"
				} else if (this.btnselect3 == "") {
					this.btnselect3 = "c"
				} else if (this.btnselect4 == "") {
					this.btnselect4 = "c"
				} else if (this.btnselect5 == "") {
					this.btnselect5 = "c"
				} else if (this.btnselect6 == "") {
					this.btnselect6 = "c"
				} else if (this.btnselect7 == "") {
					this.btnselect7 = "c"
				} else if (this.btnselect8 == "") {
					this.btnselect8 = "c"
				} else if (this.btnselect9 == "") {
					this.btnselect9 = "c"
					this.GetRUsult();
				}
			},
			btn_SelectD() {
				if (this.btnselect0 == "") {
					this.btnselect0 = "d"
				} else if (this.btnselect1 == "") {
					this.btnselect1 = "d"
				} else if (this.btnselect2 == "") {
					this.btnselect2 = "d"
				} else if (this.btnselect3 == "") {
					this.btnselect3 = "d"
				} else if (this.btnselect4 == "") {
					this.btnselect4 = "d"
				} else if (this.btnselect5 == "") {
					this.btnselect5 = "d"
				} else if (this.btnselect6 == "") {
					this.btnselect6 = "d"
				} else if (this.btnselect7 == "") {
					this.btnselect7 = "d"
				} else if (this.btnselect8 == "") {
					this.btnselect8 = "d"
				} else if (this.btnselect9 == "") {
					this.btnselect9 = "d"
					this.GetRUsult();
				}
			},
			btn_backspace() {
				// if (this.btnselect9 != "") {
				// 	this.btnselect9 = ""
				// } else if (this.btnselect8 != "") {
				// 	this.btnselect8 = ""
				// } else if (this.btnselect7 != "") {
				// 	this.btnselect7 = ""
				// } else if (this.btnselect6 != "") {
				// 	this.btnselect6 = ""
				// } else if (this.btnselect5 != "") {
				// 	this.btnselect5 = ""
				// } else if (this.btnselect4 != "") {
				// 	this.btnselect4 = ""
				// } else if (this.btnselect3 != "") {
				// 	this.btnselect3 = ""
				// } else if (this.btnselect2 != "") {
				// 	this.btnselect2 = ""
				// } else if (this.btnselect1 != "") {
				// 	this.btnselect1 = ""
				// } else if (this.btnselect0 != "") {
				// 	this.btnselect0 = ""
				// }
				if (this.btnselect0 != "") {
					this.btnselect0 = "";
					this.btnselect0 = this.btnselect1;
					this.btnselect1 = this.btnselect2;
					this.btnselect2 = this.btnselect3;
					this.btnselect3 = this.btnselect4;
					this.btnselect4 = this.btnselect5;
					this.btnselect5 = this.btnselect6;
					this.btnselect6 = this.btnselect7;
					this.btnselect7 = this.btnselect8;
					this.btnselect8 = this.btnselect9;
					this.btnselect9 = "";
				}
				this.Results1 = "";
				this.Results2 = "";
				this.Results3 = "";
				this.Results4 = "";
				this.Results5 = "";
				this.Results6 = "";
				this.Results7 = "";
			},
			btn_Clear() {
				this.btnselect0 = "";
				this.btnselect1 = "";
				this.btnselect2 = "";
				this.btnselect3 = "";
				this.btnselect4 = "";
				this.btnselect5 = "";
				this.btnselect6 = "";
				this.btnselect7 = "";
				this.btnselect8 = "";
				this.btnselect9 = "";

				this.Results1 = "";
				this.Results2 = "";
				this.Results3 = "";
				this.Results4 = "";
				this.Results5 = "";
				this.Results6 = "";
				this.Results7 = "";
			},

			GetRUsult() {
				var a0 = this.btnselect0;
				console.log(a0);
				var a1 = this.btnselect1;
				console.log(a1);
				var a2 = this.btnselect2;
				var a3 = this.btnselect3;
				var a4 = this.btnselect4;
				var a5 = this.btnselect5;
				var a6 = this.btnselect6;
				var a7 = this.btnselect7;
				var a8 = this.btnselect8;
				var a9 = this.btnselect9;
				console.log(a9);
				//var List = [];
				//const sdd=this.Getint(a0);
				this.List = [];
				//this.GetRUsult(a0);
				//console.log(intData);
				this.List.push(this.Getint(a0));
				this.List.push(this.Getint(a1));
				this.List.push(this.Getint(a2));
				this.List.push(this.Getint(a3));
				this.List.push(this.Getint(a4));
				this.List.push(this.Getint(a5));
				this.List.push(this.Getint(a6));
				this.List.push(this.Getint(a7));
				this.List.push(this.Getint(a8));
				this.List.push(this.Getint(a9));
				console.log(11111111);
				var ResturnArray = []
				for (var i = 0; i < this.List.length; i++) {
					console.log(this.List[i]);
					if ((this.List.length - i) < 3) {
						break;
					}
					var temp = this.List[i] + this.List[i + 1] + this.List[i + 2]
					ResturnArray.push(temp);
				}
				console.log(2222);
				var resturn = []
				this.Sum = 0;
				for (var i = 0; i < ResturnArray.length; i++) {
					console.log(ResturnArray[i]);
					//getResultGrid(ResturnArray[i],i);
					resturn.push(this.getResultGrid(ResturnArray[i], i));
				}


				console.log(333333);

				for (var i = 0; i < resturn.length; i++) {
					console.log(resturn[i]);
				}
				console.log(444444);
				this.Results1 = resturn[0];
				this.Results2 = resturn[1];
				this.Results3 = resturn[2];
				this.Results4 = resturn[3];
				this.Results5 = resturn[4];
				this.Results6 = resturn[5];
				this.Results7 = resturn[6];
				console.log(55555);
			},

			Getint(Data) {
				if (Data == "a") {
					return 0;
				} else if (Data == "b") {
					return 1;
				} else if (Data == "c") {
					return 2;
				} else if (Data == "d") {
					return 3;
				}
			},

			getResultGrid(Data, int) {
				console.log("sssssssss");
				if (int < 3) {
					if (Data % 2 == 0) {
						return "a";
					} else {
						return "b"
					}
				} else {
					if (Data % 2 == 0) {
						return "c";
					} else {
						return "d"
					}
				}
			}

		}
	}
</script>

<style>
	.container {
		padding: 10px;
		font-size: 14px;
		line-height: 24px;
	}

	.Topbutton {
		padding: 0px;
		height: 30px;
		width: 30px;
		line-height: 30px;
		color: black;
		text-align: center;
		vertical-align: text-top;
		font-size: 14px;
		margin: 0 auto;
		margin-left: 3px;
		border: 2px solid black;
		grid-column-gap: 10px;
		box-shadow: none;
	}

	.buttonIsEnable {
		padding: 0px;
		height: 30px;
		width: 80px;
		line-height: 30px;
		color: black;
		text-align: center;
		vertical-align: text-top;
		font-size: 14px;
		margin: 0 auto;
		margin-left: 3px;
		border: 2px black;
		grid-column-gap: 10px;
	}

	.TopGrid {
		display: grid;
		justify-content: center;
		align-self: center;
		margin-bottom: 50px;
		margin-top: 20px;
		padding: 10px;
		grid-column-gap: 5px;


	}

	.CentGrid {
		display: grid;
		justify-content: center;
		align-self: center;
		margin-bottom: 10px;
	}

	.LabelContent {
		font-size: 14px;
		padding-top: 50px;
		margin-top: 50px;
		margin-left: 20px;
		font-weight: bolder;
	}

	.resultGrid {
		display: grid;
		justify-content: center;
		align-self: center;
		margin-bottom: 10px;
		margin-left: 15px;
		margin-right: 15px;
	}
</style>